package com.jic.product.impl;

import java.lang.Long;
import java.util.List;

import com.jic.product.entity.ProductAfterSale;
import com.jic.product.mapper.ProductAfterSaleMapper;
import com.jic.product.service.ProductAfterSaleService;
import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 商品售后表
 * @author : 
 * @email : 
 * @since : 2020-01-10 07:03:01
 * @version : v1.0.0
 */
@Service
public class ProductAfterSaleServiceImpl implements ProductAfterSaleService{

    @Autowired
    private ProductAfterSaleMapper productAfterSaleMapper;

    @Override
    public long insert(ProductAfterSale productAfterSale) {
        long flag = productAfterSaleMapper.insert(productAfterSale);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return productAfterSaleMapper.delete(id);
    }

    @Override
    public long update(ProductAfterSale productAfterSale) {
        return productAfterSaleMapper.update(productAfterSale);
    }

    @Override
    public ProductAfterSale queryByPrimaryKey(Long id){
        return productAfterSaleMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<ProductAfterSale> query(ProductAfterSale productAfterSale){
        return productAfterSaleMapper.query(productAfterSale);
    }

    @Override
    public PageResult<ProductAfterSale> queryPage(ProductAfterSale productAfterSale, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<ProductAfterSale> list = productAfterSaleMapper.queryPage(startIndex, pageQuery.getLimit(), productAfterSale);
        long count = productAfterSaleMapper.queryPageCount(productAfterSale);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }

    @Override
    public ProductAfterSale getProductAfterSale(ProductAfterSale productAfterSale) {
        return productAfterSaleMapper.getProductAfterSale(productAfterSale);
    }


}